package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseFragment;
import com.isunland.managesystem.entity.DataStatus;
import com.isunland.managesystem.entity.MonthAttendanceOriginal;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/5/10 15:37
 */
public class MonthAttendanceRealtimeDetailFragment extends BaseFragment {
  public static final String EXTRA_VALUE =
      "com.isunland.managesystem.ui.MonthAttendanceRealtimeDetailFragment.EXTRA_VALUE";
  @BindView(R.id.tv_attendyearMonth) TextView tvAttendyearMonth;
  @BindView(R.id.tv_staffName) TextView tvStaffName;
  @BindView(R.id.tv_naturalDays) TextView tvNaturalDays;
  @BindView(R.id.tv_workDays) TextView tvWorkDays;
  @BindView(R.id.tv_paidSalaryDays) TextView tvPaidSalaryDays;
  @BindView(R.id.tv_rebackDescribe) TextView tvRebackDescribe;
  @BindView(R.id.tv_onPositionDays) TextView tvOnPositionDays;
  @BindView(R.id.tv_lunchFee) TextView tvLunchFee;
  @BindView(R.id.tv_lateTimes) TextView tvLateTimes;
  @BindView(R.id.tv_earlierTimes) TextView tvEarlierTimes;
  @BindView(R.id.tv_paidSickDays) TextView tvPaidSickDays;
  @BindView(R.id.tv_sickDays) TextView tvSickDays;
  @BindView(R.id.tv_outworkDays) TextView tvOutworkDays;
  @BindView(R.id.tv_privateDays) TextView tvPrivateDays;
  @BindView(R.id.tv_turnOnDays) TextView tvTurnOnDays;
  @BindView(R.id.tv_paidDays) TextView tvPaidDays;
  @BindView(R.id.tv_marriageDays) TextView tvMarriageDays;
  @BindView(R.id.tv_funeralDays) TextView tvFuneralDays;
  @BindView(R.id.tv_tripDays) TextView tvTripDays;
  @BindView(R.id.tv_prenatalDays) TextView tvPrenatalDays;
  @BindView(R.id.tv_maternityLeaveDays) TextView tvMaternityLeaveDays;
  @BindView(R.id.tv_nursingLeaveDays) TextView tvNursingLeaveDays;
  @BindView(R.id.tv_medicalDays) TextView tvMedicalDays;
  @BindView(R.id.tv_absenceDays) TextView tvAbsenceDays;
  @BindView(R.id.tv_punitiveDays) TextView tvPunitiveDays;
  @BindView(R.id.tv_extraDays) TextView tvExtraDays;
  @BindView(R.id.tv_extraPayDays) TextView tvExtraPayDays;
  @BindView(R.id.tv_statutoryHoliday) TextView tvStatutoryHoliday;
  @BindView(R.id.tv_deductionMoney) TextView tvDeductionMoney;
  @BindView(R.id.tv_overtimeNofeeTimes) TextView tvOvertimeNofeeTimes;
  @BindView(R.id.tv_lunchMoney) TextView tvLunchMoney;
  @BindView(R.id.tv_handleDesc) TextView tvHandleDesc;
  @BindView(R.id.tv_dataStatuse) TextView tvDataStatuse;
  @BindView(R.id.tv_registerName) TextView tvRegisterName;
  @BindView(R.id.tv_registerTime) TextView tvRegisterTime;
  @BindView(R.id.tv_checkorName) TextView tvCheckorName;
  @BindView(R.id.tv_checkTime) TextView tvCheckTime;
  @BindView(R.id.tv_apprManName) TextView tvApprManName;
  @BindView(R.id.tv_ApprManTime) TextView tvApprManTime;
  @BindView(R.id.tv_occupationalInjuryDays) TextView tvOccupationalInjuryDays;
  private MonthAttendanceOriginal.MonthAttendanceContent content;

  @Override public void onCreate(Bundle savedInstanceState) {
    setBack(true);
    setTitleCustom(R.string.monthAttendanceDetail);
    content = (MonthAttendanceOriginal.MonthAttendanceContent) getArguments().getSerializable(
        EXTRA_VALUE);
    super.onCreate(savedInstanceState);
  }

  @Override public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        if (NavUtils.getParentActivityName(getActivity()) != null) {
          NavUtils.navigateUpFromSameTask(getActivity());
        }
        break;

      default:
        break;
    }
    return super.onOptionsItemSelected(item);
  }

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_month_attendance_realtime, container, false);
    ButterKnife.bind(this, v);
    initData();
    return v;
  }

  public void initData() {
    tvAttendyearMonth.setText(content.getAttendyearMonth());
    tvStaffName.setText(content.getStaffName());
    tvNaturalDays.setText(content.getNaturalDays());
    tvWorkDays.setText(content.getWorkDays());
    tvPaidSalaryDays.setText(content.getPaidSalaryDays());
    tvRebackDescribe.setText(content.getRebackDescribe());
    tvOnPositionDays.setText(content.getOnPositionDays());
    tvLunchFee.setText(content.getLunchFee());
    tvPrivateDays.setText(content.getPrivateDays());
    tvMarriageDays.setText(content.getMarriageDays());
    tvFuneralDays.setText(content.getFuneralDays());
    tvMaternityLeaveDays.setText(content.getMaternityLeaveDays());
    tvSickDays.setText(content.getSickDays());
    tvPaidSickDays.setText(content.getPaidSickDays());
    tvOutworkDays.setText(content.getOutworkDays());
    tvTurnOnDays.setText(content.getTurnOnDays());
    tvTripDays.setText(content.getTripDays());
    tvLateTimes.setText(content.getLateTimes());
    tvEarlierTimes.setText(content.getEarlierTimes());
    tvPunitiveDays.setText(content.getPunitiveDays());
    tvExtraDays.setText(content.getExtraDays());
    tvPaidDays.setText(content.getPaidDays());
    tvExtraPayDays.setText(content.getExtraPayDays());
    tvStatutoryHoliday.setText(content.getStatutoryHoliday());
    tvHandleDesc.setText(content.getHandleDesc());
    tvPrenatalDays.setText(content.getPrenatalDays());
    tvNursingLeaveDays.setText(content.getNursingLeaveDays());
    tvMedicalDays.setText(content.getMedicalDays());
    tvAbsenceDays.setText(content.getAbsenceDays());
    tvDeductionMoney.setText(content.getDeductionMoney());
    tvOvertimeNofeeTimes.setText(content.getOvertimeNofeeTimes());
    tvLunchMoney.setText(content.getLunchMoney());
    tvOccupationalInjuryDays.setText(content.getOccupationalInjuryDays());

    String dataStatus = content.getAttenddataStatus();
    if (DataStatus.PUBLIS.equals(dataStatus)) {
      tvDataStatuse.setText(R.string.publish);
    } else if (DataStatus.NEW.equals(dataStatus)) {
      tvDataStatuse.setText(R.string.draft);
    } else if (DataStatus.SUBMIT.equals(dataStatus)) {
      tvDataStatuse.setText(R.string.waitCheck);
    } else if (DataStatus.NEWBACK.equals(dataStatus)) {
      tvDataStatuse.setText(R.string.removeCheck);// 返回修改
    } else if (DataStatus.ORGBACK.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.ORGBACK));// 部门返回
    } else if (DataStatus.ORGPUBLISH.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.ORGPUBLISH));// 部门通过
    } else if (DataStatus.ORGUNITBACK.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.ORGUNITBACK));// 单位返回
    } else if (DataStatus.ORUNITPUBLISH.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.ORUNITPUBLISH));// 单位通过
    } else if (DataStatus.PERSONCHECK.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.PERSONCHECK));// 个人核查
    } else if (DataStatus.ARCHIVE.equals(dataStatus)) {
      tvDataStatuse.setText(DataStatus.getDataStatusName(DataStatus.ARCHIVE));// 已归档
    }
    tvRegisterName.setText(content.getAttendRegManName());//登记人
    tvRegisterTime.setText(content.getAttendRegTime());
    tvCheckorName.setText(content.getAttendCheckManName());
    tvCheckTime.setText(content.getAttendCheckTime());
    tvApprManName.setText(content.getAttendApprManName());
    tvApprManTime.setText(content.getAttendApprTime());
  }

  public static MonthAttendanceRealtimeDetailFragment newInstance(
      MonthAttendanceOriginal.MonthAttendanceContent content) {

    Bundle args = new Bundle();
    args.putSerializable(EXTRA_VALUE, content);
    MonthAttendanceRealtimeDetailFragment fragment = new MonthAttendanceRealtimeDetailFragment();
    fragment.setArguments(args);
    return fragment;
  }
}
